// 在reg-script.js中添加以下函数
function showAlert(message, type = 'info', duration = 3000) {
    const alertBox = document.getElementById('customAlert');
    const content = alertBox.querySelector('.alert-content');

    // 移除所有状态类
    content.className = 'alert-content';
    alertBox.className = 'custom-alert';

    // 设置内容
    alertBox.querySelector('.alert-message').textContent = message;
    alertBox.classList.add('show', `alert-${type}`);

    // 自动关闭
    const timer = setTimeout(() => {
        alertBox.classList.remove('show');
    }, duration);

    // 手动关闭
    const closeBtn = alertBox.querySelector('.alert-close');
    closeBtn.onclick = () => {
        clearTimeout(timer);
        alertBox.classList.remove('show');
    };
}

document.addEventListener('DOMContentLoaded', () => {
    // 主题切换功能
    const themeSwitch = document.getElementById('themeSwitch');
    const body = document.body;

    // 检查本地存储中的主题偏好
    const savedTheme = localStorage.getItem('theme');
    if (savedTheme === 'dark') {
        body.classList.add('dark-theme');
        themeSwitch.checked = true;
    }

    // 切换主题
    themeSwitch.addEventListener('change', function() {
        if (this.checked) {
            body.classList.add('dark-theme');
            localStorage.setItem('theme', 'dark');
        } else {
            body.classList.remove('dark-theme');
            localStorage.setItem('theme', 'light');
        }
    });
})
